package com.itbour.web.action.tg;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.itbour.com.page.Page;
import com.itbour.common.base.BaseAction;
import com.itbour.dto.com.UserInfoDto;
import com.itbour.service.tg.SaleRankInfoService;
import com.opensymphony.xwork2.ActionContext;

/**
 * @author LQ 获取销售月排行榜
 * */
public class GetSaleRankInfoAction extends BaseAction {

	/**
	 */
	private static final long serialVersionUID = 1L;
	private SaleRankInfoService saleRankInfoService;
	private Map<String, Object> mapResult=new HashMap<String, Object>();
	

	/**查看销售排行榜
	 * @return
	 * @throws Exception 
	 */
	public String getPartnerSaleRank() throws Exception{
		Map<String, Object> session=ActionContext.getContext().getSession();
		UserInfoDto user=(UserInfoDto)session.get("user");
		HttpServletRequest request =ServletActionContext.getRequest();
		if(user!=null && user.getUser_id()!=null){
			Map<String, Object> parm=new HashMap<String, Object>();
			Integer pageNo=Integer.parseInt(request.getParameter("page"));
			Integer pageSize =Integer.parseInt(request.getParameter("rows"));
			Integer year =null;
			if(request.getParameter("year")!=null){
				year = Integer.parseInt(request.getParameter("year"));
				parm.put("year",year);
			}
			Integer month = null;
			if(request.getParameter("month")!=null){
				month = Integer.parseInt(request.getParameter("month"));
				parm.put("month",month);
			}
			Integer dist = null;
			if(request.getParameter("dist")!=null){
				dist = Integer.parseInt(request.getParameter("dist"));
				parm.put("dist",dist);
			}
			String mobile=null;
			if(request.getParameter("mobile")!=null){
				mobile = request.getParameter("mobile");
				parm.put("mobile",mobile);
			}
			Integer city = null;
			if(request.getParameter("city")!=null){
				city = Integer.parseInt(request.getParameter("city"));
				parm.put("city",city);
			}
			Integer prov = null;
			if(request.getParameter("prov")!=null){
				prov = Integer.parseInt(request.getParameter("prov"));
				parm.put("prov",prov);
			}
			Page p=saleRankInfoService.getPartnerSaleRank(parm, pageNo, pageSize);
			mapResult.put("total", p.getTotalCount());
			mapResult.put("rows", p.getResult());	
		}else{
			mapResult.put("error","no");
		}
		return SUCCESS;
	}


	
	
	
	
	public SaleRankInfoService getSaleRankInfoService() {
		return saleRankInfoService;
	}
	public void setSaleRankInfoService(SaleRankInfoService saleRankInfoService) {
		this.saleRankInfoService = saleRankInfoService;
	}
	public Map<String, Object> getMapResult() {
		return mapResult;
	}
	public void setMapResult(Map<String, Object> mapResult) {
		this.mapResult = mapResult;
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
}
